﻿namespace Sidvall.Office
{
    public class WorksheetCell : Sidvall.Office.IWorksheetCell
    {
        #region Public Members

        #region CellFormat

        private IWorksheetCellFormat _CellFormat;
        public IWorksheetCellFormat CellFormat
        {
            get
            {
                if (_CellFormat == null)
                    _CellFormat = new WorksheetCellFormat(this.InternalWorksheetCell.CellFormat);
                return _CellFormat;
            }
        }

        #endregion
        #region Comment

        public string Comment
        {
            get
            {
                if (!this.HasComment)
                    return null;
                return this.InternalWorksheetCell.Comment.Text.UnformattedString;
            }
            set
            {
                if (value == null)
                {
                    this.InternalWorksheetCell.Comment = null;
                }
                else
                {
                    if (this.InternalWorksheetCell.Comment == null)
                        this.InternalWorksheetCell.Comment = new Infragistics.Documents.Excel.WorksheetCellComment();
                    this.InternalWorksheetCell.Comment.Text.UnformattedString = value;
                }
            }
        }

        #endregion
        #region HasComment

        public bool HasComment
        {
            get
            {
                return this.InternalWorksheetCell.HasComment;
            }
        }

        #endregion
        #region Value

        public object Value
        {
            get
            {
                return this.InternalWorksheetCell.Value;
            }
            set
            {
                this.InternalWorksheetCell.Value = value;
            }
        }

        #endregion

        #region GetText

        public string GetText()
        {
            return this.InternalWorksheetCell.GetText();
        }
        public string GetText(TextFormatMode textFormatMode)
        {
            return this.InternalWorksheetCell.GetText(Excel.GetTextFormatMode(textFormatMode));
        }

        #endregion
        #region ToString

        public override string ToString()
        {
            return "WorksheetCell - Sidvall.Office.IG";
        }

        #endregion

        #endregion
        #region Private Members

        internal Infragistics.Documents.Excel.WorksheetCell InternalWorksheetCell { get; set; }

        #endregion
        #region Constructors

        public WorksheetCell(Infragistics.Documents.Excel.WorksheetCell worksheetCell)
        {
            this.InternalWorksheetCell = worksheetCell;
        }

        #endregion
    }
}
